599B - Spongebob and Joke - CodeForces Solution


implementation *1500

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,m,f[100010],b[100010],f_num[100010],f_where[100010];
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin >> f[i];
		f_num[f[i]]++,f_where[f[i]] = i;
	}
	for(int i=1;i<=m;i++)
	{
		cin>>b[i];
		if(!f_where[b[i]])
		{
			cout << "Impossible";
			return 0; 
		}	
	}
	for(int i=1;i<=m;i++)
		if(f_num[b[i]]>1)
		{
			cout<<"Ambiguity";
			return 0; 
		}
	cout << "Possible"<<endl;
	for(int i=1;i<=m;i++) cout<<f_where[b[i]]<<" ";
	return 0;
}
	 		 				  	    			 			 		   	


Comments

Submit
0 Comments
More Questions

465A - inc ARG
1260A - Heating
1740D - Knowledge Cards
1028A - Find Square
1370B - GCD Compression
888D - Almost Identity Permutations
1106C - Lunar New Year and Number Division
849B - Tell Your World
1650E - Rescheduling the Exam
899C - Dividing the numbers
1023C - Bracket Subsequence
1579D - Productive Meeting
1749E - Cactus Wall
1682C - LIS or Reverse LIS
578A - A Problem about Polyline
1038E - Maximum Matching
1141C - Polycarp Restores Permutation
1685A - Circular Local MiniMax
432B - Football Kit
10C - Digital Root
743B - Chloe and the sequence
909D - Colorful Points
1283C - Friends and Gifts
605B - Lazy Student
1687B - Railway System
61D - Eternal Victory
588B - Duff in Love
12C - Fruits
447B - DZY Loves Strings
325A - Square and Rectangles